package com.nx.project.javacore.factory;

public class BreakfastFactory02 {

    /**
     * 使用反射来生产实例
     * @param id
     * @return
     */
    public Breakfast create(String id) throws Exception {
        if (id==null){
            throw  new RuntimeException("name is null");
        }

        Class<?> aClass = Class.forName("com.nx.project.javacore.factory.impl." + id);
        return (Breakfast) aClass.newInstance();

    }
}
